package com.cmschina.mybatis;

import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @author: li chao
 * @Desc:
 * @create: 2024-08-06 15:12
 **/
@Configuration
public class MybatisConfig {

    @Autowired
    private SqlSessionFactory sqlSessionFactory;

    @PostConstruct
    public void add() {
        MybatisInterceptor interceptor = new MybatisInterceptor();
        sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
    }
}
